home *** CD-ROM | disk | FTP | other *** search
- ;----------------------------------------------------------------------
- ; TODAY.ASM (c) 1983
- ; IBM PC Macro Assembler
- ; Steve Manes, Roxy Recorders, NYC Sept 15, 83
- ; all commercial rights reserved
- ; Writes current system date, in correspondence form,
- ; to an ASCII data file DATE.DOC, on the current drive.
- ;
- ; code typed by
- ; Joseph MACK
- ; Dept. Chemistry, UMBC
- ; 5401 Wilkens Ave
- ; Catonsville,MD,21228
- ; 301-455-2564 (afternoons best)
- ; from the text of an article published in PC World, Feb'84, p212
- ;--------------------------------------------------------------------
- Title TODAY
- ;------------------;
- ;Program constants ;
- ;------------------;
- cr equ 13
- lf equ 10
-
- CSEG SEGMENT PARA 'CODE'
- TODAY PROC FAR
- ASSUME CS:CSEG,DS:CSEG,ES:CSEG,SS:CSEG
- ORG 100h
- Begin: ; Program code begins
- ; Write intro message and fetch current system date
- lea dx,prog_name
- mov ah,9 ; PRINT STRING function
- int 21h ; display program title
- mov ah,2Ah ; FETCH SYSTEM DATE function
- int 21h ; on exit : CX= Year (1980-2099)
- ; DH= Month (1-12)
- ; DL= Day (1-31)
- push cx ; save year on stack
- push dx ; save month/day on stack
- ; Position BX pointer to correct month in string
- xor bx,bx ; clear the count register
- mov bl,dh ; current month to BL counter
- lea di,month ; point to top of month variable
- dec bx ; month=month-1
- jz write_month ; month=0 ? (DI already positioned)
- month_offset: ; Scan months for BX offset
- mov al,' ' ; char for ASCII blank
- mov cx,12 ; dummy value for SCASB instruction
- repne scasb ; scan string
- dec bl ; decrement counter BL
- jz write_month ; if BL=0, leave loop
- inc di ; else, offset to next character
- jmp month_offset ; after blank and loop again
- write_month: ; Write month to DTA buffer
- mov si,di ; Xfer string pointer to SI
- lea di,dta ; position DI pointer to dta variable
- mov ah,' ' ; character to find
- w_ml:
- mov al,[si] ; get char at SI
- mov [di],al ; move to DTA
- inc si ; inc pointer registers
- inc di
- cmp al,ah ; see if it's an ASCII space
- je eof ; yes, goto eof
- jmp w_ml
- eof: ; Move pointer to end of DTA string
- add di,8 ; end of text string in buffer
- pop dx ; restore month/day
- pop bx ; restore year ( orig pushed onto CX )
- cmp dl,10 ; is day a two-char print?
- jb eof1 ; no, pointer already positioned
- inc di ; yes, add room for another digit
- eof1: ; add eof mark 1Ah
- ; Note: Only 1Ah is necc. The extra 0 is something
- ; I always add after EOF mark for superstitious reasons
- ; mostly.
- mov byte ptr[di],0 ; put a zero there
- dec di ; back up string pionter
- mov byte ptr[di],26 ; put ASCII EOF mark there
- push di ; save ASCII end of string pointer
- year: ; Write year
- mov ax,bx ; copy year to math register
- call WRITE_ASCII ; convert it & write it to string
- comma: ; Write a comma and a blank
- dec di ; back up pointer
- mov byte ptr[di],' ' ; write a ' '
- dec di ; back up pointer
- mov byte ptr[di],',' ; write a ','
- day: ; Write day of month
- mov ax,dx ; move month/day to math register
- mov ah,0 ; clear out month
- call WRITE_ASCII ; convert it and write it to string
- pop di ; restore end of ASCII string pointer
- ; for success message print
- ; Create file directory heading
- lea dx,fcb ; point at file control block
- mov ah,16h ; CREAT FILE function
- int 21h
- cmp al,0FFh ; check status, Directory full?
- je error1 ; yes, print messg and exit
- ; Set FCB current record and random record fields
- lea si,fcb+14 ; point to record size
- mov word ptr[si],20 ; record size = 20 bytes
- add si,18 ; point to current record field
- mov byte ptr[si],0 ; current record = 0
- inc si ; next byte
- mov word ptr[si],0 ; random record number (low) = 0
- add si,2 ; one word over
- mov word ptr[si],0 ; random record number (high) = 0
- ; Set up DTA
- lea dx,dta ; point at disk transfer buffer
- mov ah,1Ah ; Set DISK TRANSFER ADDRESS funct
- int 21h
- ; Write data to disk
- lea dx,fcb
- mov cx,1 ; # of records to write
- mov ah,22h ; RANDOM WRITE function
- int 21h
- cmp al,1 ; disk full?
- je error2 ; yes, print error mssg
- ; Record written successfully. Close file & exit
- lea dx,fcb
- mov ah,10h ; CLOSE FILE function
- int 21h
- cmp al,0FFh ; check status. File closed properly ?
- je error3 ; no, print error mssg
- mov byte ptr[di],'$' ; replace EOF mark with EOS char
- ; for video display of date
- lea dx,success ; point to success mssg and exit
- jmp exit
- error1:
- lea dx,failure1 ; point to error mssg
- jmp exit ; and exit
- error2:
- lea dx,failure2
- jmp exit
- error3:
- lea dx,failure3
- jmp exit
- exit:
- mov ah,9 ; PRINT STRING function
- int 21h ; print DX mssg
- lea dx,cr_lf ; cr,lf sequence
- mov ah,9 ; PRINT STRING function
- int 21h
- int 20h ; & exit to DOS
-
- WRITE_ASCII PROC
- ; This proc converts and unsigned binary number
- ; to an ASCII string pointed at by DI
- ; At entry, AX= number to be converted
- ; DI= character designation address +1
- push dx ; save registers used
- push si
- mov si,10 ; divisor
- convert:
- xor dx,dx ; clear remainder register
- div si ; divide AX by 10
- add dx,'0' ; cnvert dx remainder to ASCII
- dec di ; back up string pointer
- mov byte ptr[di],dl ; write ASCII number to DI string
- cmp ax,0 ; finished?
- ja convert ; no, convert next number
- pop si ; yes, restore registers
- pop dx
- ret ; ret to caller
- WRITE_ASCII ENDP
- TODAY ENDP ; end of executable code
- ;----------------------;
- ; Program data ;
- ;----------------------;
- fcb db 0,'DATE DOC'; Standard file control
- db 28 dup(0)
- month db 'January '
- db 'February '
- db 'March '
- db 'April '
- db 'May '
- db 'June '
- db 'July '
- db 'August '
- db 'September '
- db 'October '
- db 'November '
- db 'December '
- prog_name db cr,lf,"TODAY.COM (c) 1983 Steve Manes",cr,lf,'$'
- ; Note, there is no '$' char after a success mssg
- ; The program will supply this
- success db "Today's date written to DATE.DOC",cr,lf
- dta db 21 dup(' ') ; disk transfer buffer
- failure1 db "Directory Full$"
- failure2 db "Disk Full$"
- failure3 db "File close error$"
- cr_lf db cr,lf,'$' ; cr,lf
-
- CSEG ENDS ; end of seg
- END BEGIN ; end of assembly
- Author : Steve Manes
- Roxy Recorders Inc
- 648 Broadway
- NYC,NY,10012
- (212)-533-1692
- (212)-475-6571
-